<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>设置时间</title>
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <script src="/js/layui/layui.all.js"></script>
    <script src="/admin/js/token.js"></script>
</head>
<style>

</style>
<body style="background: white;height: 100%;">
<div>
    <div class="layui-form" style="padding: 10px 0px 30px 0px">

        <div class="layui-inline">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="end" placeholder="开始时间">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 20px">
            <div class="layui-input-block">
                <button class="layui-btn" type="button" id="confirm">确定</button>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    layui.use(['laydate', 'form'], function () {
        var $ = layui.$;
        var form = layui.form;
        var laydate = layui.laydate;
        var data = layui.data("stationdata");
        var terminalid = layui.data("terminalid")
        var terminalkeyid = data.getdata.terminal_key_id;
        var terminal_id = terminalid.terminalid.terminal_id

        laydate.render({
            elem: "#end",
            type: "datetime",
        })
        $("#confirm").click(function () {
            $.ajax({
                type: "post",
                url: "/admin/terminal/TerminalByIdUpdateTermainal_keyByIdupdate",
                data: {
                    terminalId: terminal_id,
                    terminalKeyId: terminalkeyid,
                    TerminalKeyEndTime: $("#end").val()
                },
                success: function (res) {
                    switch (res.code) {
                        case 3:
                            layer.msg(res.data, {
                                icon: 2
                            })
                            break;
                        case 2:
                            layer.msg(res.data, {
                                icon: 2
                            })
                            break;
                        case 0:
                            layer.msg(res.data, {
                                icon: 1
                            })
                            setTimeout(function () {
                                // 格式正m 确充值
                                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index);    //关闭弹出层
                                window.parent.location.reload();   //刷新父界面
                            }, 1400)
                            break;
                    }
                }
            })
        })
    })
</script>
</html>